package com.duoec.dw.lineage.service.impl.desc;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author xuwenzhen
 */
public abstract class BaseTableDescTypeProcessor implements TableDescTypeProcessor {
    private static final Logger logger = LoggerFactory.getLogger(BaseTableDescTypeProcessor.class);
    protected static final String STR_DATA_TYPE = "data_type";
    protected static final String STR_COMMENT = "comment";
    protected static final String STR_COL_NAME = "col_name";
    protected static final String STR_NULL = "NULL";
    protected static final String SUB_TYPE_STR = "param";
    protected static final String DOT = ".";

    protected String getColValue(ResultSet rs, String columnName) {
        try {
            String string = rs.getString(columnName);
            if (string != null) {
                return string.trim();
            }
            return null;
        } catch (SQLException e) {
            logger.error("无法获取{}字段", columnName, e);
            return null;
        }
    }
}
